package com.lumlord.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lumlord.common.domain.LumlordApi;
import com.lumlord.common.exception.BusinessException;
import com.lumlord.util.JdbcTemplateUtils;
import com.lumlord.util.MD5Util;

/**
   *  开发相关 api注入
 * @author GPF
 *
 */

@Service
public class LumlordApiService {
	
	/**
	 * api 注入
	 * @throws BusinessException
	 */
	public void registerApi(LumlordApi api) throws BusinessException {
		
		String vueCode  = MD5Util.getMD5String(api.getVueCode());
		
		api.setVueCode(vueCode); //加密
		
		/*LumlordApi dbApi = jdbcTemplateUtils.queryOne("SELECT ID FROM "+jdbcTemplateUtils.getCoreDb("t_action")+" WHERE VUE_CODE=?", LumlordApi.class, vueCode);
		if(null == dbApi) {
			jdbcTemplateUtils.save(api);
		}else {
			api.setId(dbApi.getId());
			jdbcTemplateUtils.updateById(api);
		}*/
	}


	/**
	 * api 注入
	 * @throws BusinessException
	 */
	public void menuUrlisExist(LumlordApi api) throws BusinessException {

		String vueCode  = MD5Util.getMD5String(api.getVueCode());

		api.setVueCode(vueCode); //加密

		/*LumlordApi dbApi = jdbcTemplateUtils.queryOne("SELECT ID FROM "+jdbcTemplateUtils.getCoreDb("t_action")+" WHERE VUE_CODE=?", LumlordApi.class, vueCode);
		if(null == dbApi) {
			jdbcTemplateUtils.save(api);
		}else {
			api.setId(dbApi.getId());
			jdbcTemplateUtils.updateById(api);
		}*/
	}

	@Autowired
	private JdbcTemplateUtils jdbcTemplateUtils;
}
